﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using QueryBuilder.Controls.Configuration;
using QueryBuilder.Core.Query;
using QueryBuilder.Core.Visualization.QueryVisualization;

namespace QueryBuilder.Controls.Samples
{
    /// <summary>
    /// Interaction logic for Sample.xaml
    /// </summary>
    public partial class Sample : UserControl
    {
        public Sample()
        {
            this.InitializeComponent();
            Application.Current.Resources.Add("ComparisonCollection", new List<string> {"OR", "AND", "XOR"});

            var expr1 = new VisualizableExpression {Comparison = Comparisons.OR};
            expr1.AddChild(new VisualizableVariable<bool>(true));
            expr1.AddChild(new VisualizableVariable<bool>(false));

            var expr2 = new VisualizableExpression {Comparison = Comparisons.OR};
            expr2.AddChild(new VisualizableVariable<bool>(true));
            expr2.AddChild(new VisualizableVariable<bool>(false));

            var conditionVisualizable = new VisualizableCondition() {Comparison = Comparisons.AND};
            conditionVisualizable.AddChild(expr1);
            conditionVisualizable.AddChild(expr2);

            var sqlConstraintVisualizerViewModel = new SqlConstraintVisualizerViewModel();

            Visualizator.DataContext = sqlConstraintVisualizerViewModel;

            sqlConstraintVisualizerViewModel.ComparisonTemplateConfiguration = (ComparisonTemplateConfiguration)Resources["ComparisonTemplateConfiguration"];

            sqlConstraintVisualizerViewModel.VisualizationConfig = (VisualizationConfig)Resources["DefaultConfiguration"];
            sqlConstraintVisualizerViewModel.VisualizableConstraints.Add(conditionVisualizable);

            sqlConstraintVisualizerViewModel.ComparisonCollection.Add("AND");
            sqlConstraintVisualizerViewModel.ComparisonCollection.Add("XOR");
            sqlConstraintVisualizerViewModel.ComparisonCollection.Add("OR");
            
        }
    }
}